\documentclass[compress, orange]{beamer}
\usetheme{Warsaw}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage[all]{xy}
\usepackage{pgfpages}
\newtheorem{thm}{Theorem}
\newcommand{\E}{\mathbb{E}}
\DeclareMathOperator{\sample}{sample}
\DeclareMathOperator{\length}{length}
\DeclareMathOperator{\axis}{axis}
\DeclareMathOperator{\bones}{bones}
\DeclareMathOperator{\return}{return}
\DeclareMathOperator{\updateMesh}{UpdateMesh}
\DeclareMathOperator{\getTranslationMatrix}{getTranslationMatrix}
\DeclareMathOperator{\getRotationMatrix}{getRotationMatrix}
\title{Inverse Kinematics Solver and Mesh Walker}
\date{\today}
\author{Jason Liang, Bharath Ramsundar, Teng Yi}

\begin{document}
\maketitle

\begin{frame}
\frametitle{Inverse Kinematics and Walking Meshes}

We have programmed an Inverse Kinematics Solver that solves for
arms with three bones and two joints. We then proceeded to write a Skeleton
class that uses the IK solver for each body component to 
animate a realistic walking skeleton. We attached meshes
to the skeleton, and moved the meshes using the transformation
matrices associated with the nearest bone
\end{frame}

\begin{frame}
\frametitle{Local Coordinates}
\includegraphics[width=3in]{ik_graph.png}
\end{frame}

\begin{frame}
\frametitle{Compute Transformation Matrix of Arm}
\begin{algorithm}[H]
\caption{TRANSFORMATION($\axis_1,\axis_2,\axis_3, \theta_1, \theta_2, \theta_3$)}
\begin{algorithmic}[1]
\STATE $M = I$
\STATE $\bones = \text{bones in arm}$
\FOR {$i = 1 \to 3$}
    \STATE $T_i = \getTranslationMatrix(\bones[i].\length)$
    \STATE $R_i = \getRotationMatrix(\axis_i,\theta_i)$
    \STATE $M = R_i T_i M$
\ENDFOR
\STATE $\return M$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[H]
\caption{p($\axis_1,\axis_2,\axis_3, \theta_1, \theta_2, \theta_3$)}
\begin{algorithmic}[1]
\STATE $M = \text{TRANSFORMATION}(\axis_1,\axis_2,\axis_3, \theta_1, \theta_2, \theta_3)$
\STATE $\return M * (0,0,0,1)$
\end{algorithmic}
\end{algorithm}
\end{frame}


\begin{frame}
\frametitle{Inverse Kinematics}
\begin{algorithm}[H]
\caption{INVERSE KINEMATICS}
\begin{algorithmic}[1]
    \STATE $\psi = (\axis_1,\axis_2,\axis_3, \theta_1, \theta_2, \theta_3)$
    \STATE $e = \text{ending position}$
    \WHILE {$\|p(\psi) - e\| >= \epsilon$}
        \STATE  $J = getJacobian(\psi)$
        \STATE  $USV^T = getSVD(J)$
        \STATE  $\psi = \psi - VS^{-1}U^T(p(\psi) - e)$
        \STATE  $\updateMesh()$
    \ENDWHILE
\end{algorithmic}
\end{algorithm}
\end{frame}

\end{document}
